<template>
  <AgGridVue class="ag-grid-vue" v-bind="props" :theme="myTheme" :locale-text="localeText">
  </AgGridVue>
</template>

<script lang="ts" setup generic="T extends object">
import { AllCommunityModule, ModuleRegistry, themeQuartz } from 'ag-grid-community'
import { RowGroupingModule, LicenseManager } from 'ag-grid-enterprise'
import { AgGridVue } from 'ag-grid-vue3' // Vue Data Grid Component
import type { IAgGridProps } from './BaseAgGrid'

// Register all Community features
ModuleRegistry.registerModules([AllCommunityModule, RowGroupingModule])
LicenseManager.setLicenseKey(
  'AgGridLicense66fwc79n[NORMAL][v0102]_NDA3MDk2NjQwMDAwMA==80908dd5fb71b58d3ce28b2ed320216d',
)

const myTheme = themeQuartz.withParams({
  browserColorScheme: 'inherit',
  headerFontFamily: [
    '-apple-system',
    'BlinkMacSystemFont',
    'Segoe UI',
    'Roboto',
    'Oxygen-Sans',
    'Ubuntu',
    'Cantarell',
    'Helvetica Neue',
    'sans-serif',
  ],
  headerFontSize: 14,
  headerFontWeight: 500,
  iconSize: 16,
  rowVerticalPaddingScale: 1,
  spacing: 2,
})

type IProps<T> = Omit<
  IAgGridProps<T>,
  | 'suppressMakeColumnVisibleAfterUnGroup'
  | 'suppressRowClickSelection'
  | 'groupSelectsChildren'
  | 'suppressRowDeselection'
  | 'unSortIcon'
  | 'suppressLoadingOverlay'
  | 'enableRangeSelection'
  | 'enableRangeHandle'
  | 'enableFillHandle'
  | 'suppressClearOnFillReduction'
  | 'suppressRowGroupHidesColumns'
  | 'suppressCopyRowsToClipboard'
  | 'groupSelectsFiltered'
  | 'groupRemoveSingleChildren'
  | 'groupRemoveLowestSingleChildren'
  | 'suppressMultiRangeSelection'
  | 'suppressPropertyNamesCheck'
  | 'rowMultiSelectWithClick'
  | 'suppressBrowserResizeObserver'
  | 'suppressCopySingleCellRanges'
  | 'suppressAdvancedFilterEval'
>

const props = defineProps<IProps<T>>()

const localeText = {
  page: '页',
  more: '更多',
  to: '到',
  applyFilter: '确定',
  resetFilter: '重制',
  clearFilter: '清除',
  cancelFilter: '取消',
  of: 'of',
  loadingOoo: '加载中...',
  selectAll: '查询全部',
  searchOoo: '查询...',
  blanks: '空白',
  filterOoo: '过滤...',
  blank: '为空',
  notBlank: '不为空',
  equals: '相等',
  notEqual: '不相等',
  lessThan: '小于',
  greaterThan: '大于',
  lessThanOrEqual: '小于等于',
  greaterThanOrEqual: '大于等于',
  inRange: '范围',
  contains: '包含',
  notContains: '不包含',
  startsWith: '开始于',
  endsWith: '结束于',
  group: '目录',
  columns: '列',
  filters: '筛选',
  values: '值',
  noRowsToShow: '数据为空',
  groupBy: '排序',
  ungroupBy: '不排序',
  resetColumns: '重置列',
  expandAll: '展开全部',
  collapseAll: '关闭',
  toolPanel: '工具面板',
  export: '导出',
  csvExport: '导出为CSV格式文件',
  excelExport: '导出到Excel',

  none: '无',

  copy: '复制',
  copyWithHeaders: '携带表头复制',
  ctrlC: 'ctrl + C',
  paste: '粘贴',
  ctrlV: 'ctrl + V',

  autosizeThiscolumn: '本列宽度自适应',
  autosizeAllColumns: '本表宽度自适应',

  // Menu
  pinColumn: '固定列',
  pinLeft: '固定在左',
  pinRight: '固定在右',
  noPin: '不固定',

  pivotMode: '仅显示聚合',
  groups: '行分组',
  rowGroupColumnsEmptyMessage: '将列拖动至此处进行数据分组',
  valueColumnsEmptyMessage: '将列拖动至此处进行数据聚合运算',
  pivots: 'Column Labels',
  pivotColumnsEmptyMessage: 'Drag here to set column labels',
}
</script>

<style scoped>
.ag-grid-vue {
  height: 500px;
}
</style>
